<template>
	<view>
		<tabnav :title="data.title" :col="back"></tabnav>
		<view class="wid90 mar">
			<view style="height: 20rpx;"></view>
			<rich-text :nodes="data.content"></rich-text>
		</view>
	</view>
</template>

<script>
	import tabnav from "../common/tabnav/tabnav.vue"
	export default {
		components: {
			tabnav,
		},
		data() {
			return {
				back: uni.getStorageSync('back'),
				data: '',
				id: ''
			}
		},
		onLoad(options) {
			this.id = options.id
			this.list(options.xq)
		},
		methods: {
			list(xq){
				var that = this
				uni.showLoading({
					title:'加载中...'
				})
				var url = ''
				if(xq == 0){
					url = 'api/qianyu_dzq/applet_guide_detail'
				}else if(xq == 1){
					url = 'api/qianyu_dzq/applet_about_my_detail'
				}else if(xq == 2){
					url = 'api/qianyu_dzq/applet_question_detail'
				}
				
				uni.request({
					url: that.global.url+url,
					method: 'POST',
					header:{'site-id':that.global.site_id},
					data: {
						id: that.id
					},
					success(res) {
					    let result = res.data
					    if(result.code == 1){
							// 有style的写法
							var data = result.data
							data.content = data.content.replace(/<img/gi, "<img class='richImg'");
							console.log(data);
							that.data = data
					    }else{
					        uni.showToast({
					            title: result.msg,
					            icon:'none',
								duration: 2000
					        })
					    }
					},
					complete() {
						uni.hideLoading()
					}
				})
			},
		}
	}
</script>

<style>
	.richImg {
	    width: 100% !important;
	    height: auto !important;
	}
</style>
